<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>VUE Template</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
    <div id="root">
        <h2>{{msg}}</h2>
        <school></school>
        <hr>
    </div>
    <div id="root2">
        <hello></hello>
    </div>
</body>
    <script type="text/javascript">
        Vue.config.devtools = true

        //创建school组件
        const school = Vue.extend({
            template:`
            <div>
                <h2>学校名称：{{schoolName}}</h2>
                <h2>学校地址：{{address}}</h2>
                <button @click="showName">点我提示学校名</button>
            </div>
            `
            ,
            data(){
                return {
                    schoolName:'xxx',
                    address:'南京'
                }
            },
            methods: {
                showName(){
                    alert(this.schoolName)
                }
            },
        })


        const vm = new Vue({
            el:'#root',
            data:{
                msg:'hello'
            },
            //注册组件
            components:{
                school,

            }
        })

    </script>
</html>